<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    body {
      padding: 100px;
    }

    textarea {
      width: 200px;
      height: 100px;
      border: 1px solid pink;
      outline: none;
      resize: none;
    }

    ul {
      margin-top: 50px;
    }

    li {
      width: 300px;
      padding: 5px;
      background-color: rgb(245, 209, 243);
      color: red;
      font-size: 14px;
      margin: 15px 0;
    }

    li a {
      float: right;
    }
  </style>
</head>
<body>
<textarea name="" id=""></textarea>
<button>发布</button>
<ul>

</ul>
<script>
  var ul = document.querySelector('ul');
  var btn = document.querySelector('button');
  var text = document.querySelector('textarea');

  document.body.removeChild(btn);

  btn.onclick = function () {
    var li = document.createElement('li');
    li.innerHTML = text.value + `<a href="javascript:;">删除</a>`;
    li.children[0].onclick = function(){
      // console.log(this.parentNode);
      // console.log(this.parentNode.parentNode);
      this.parentNode.parentNode.removeChild(this.parentNode);
    };
    ul.appendChild(li);
    text.value = '';


  }
</script>
</body>
</html>